<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆</title>
<script language="JavaScript"  type="text/javascript"  src="jquery-2.1.4.js"></script>
<script language="JavaScript"  type="text/javascript"  src="jquerysession.js"></script>
<script language="JavaScript" type="text/javascript" src="Ajax.js"></script>

<link  rel="stylesheet" href="style.css">

<script type="text/javascript">

$(function(){
	$("#submitId").click(function(){	
		/* alert("---"); */
		
		//检查用户名和密码
	    if(!$("#userName").val())
	   	{
	    	alert("请输入用户名!");
	    	$("#userName").focus();    	
	   	}	    
	    else if(!$("#studentID").val())
	   	{
	    	alert("请输入学号!");
	    	$("#studentID").focus();
	   	}
	    else//已填写用户名和密码时跳转 
	    { 	
	    	 /* $.ajax({
	    		  type: "POST",
	    		  url: "UserLogin",
	    		  data:"data="+$('#userName').val()+","+$('#studentID').val(),
	    		  success: function(msgXML)
			      {
	    			  location.href="showPage.jsp";
			    	
			      }
	    	 }); */
	    	 
	    	 
	    	var params = $('#form2').serialize();
	    	 
	    	 alert(params);
	    	 
	    	 $.post("UserLogin",params,function(data,status){  
                if(status=="success"){  
                   alert("数据加载成功");  //加载数据  
                   
                   location.href='showPage.jsp';
                   
                  	/* alert("k"); */
                }else{  
                    alert("数据加载失败");  
                }  
	         });
	    	 
	    	
	    	 
	    	 
	    	
	    	/* location.href = "UserLogin?userName="+encodeURI($("#userName").val())+"&studentId="+encodeURI($("#studentID").val());   */
	    }
	})
});
		
</script>

</head>


<body>
	<div class="bodyStyle">  
		<div  class="loginstyle">
			<div class="textstyle"> 
				<form id="form2">
					用户名:<input type="text" id="userName" name="userName"/><br><br>				
					学号: <input type="text" id="studentID" name="studentID"/><br><br>	
					<span style="padding-left:190px;"><button id="submitId">提交</button></span>
				</form>
			</div>			
		</div>	
	</div>
	
</body>
</html>